from flask_restful import Resource

from restful.api__.session import login_required_current_user_generate, uid_required_target_user_generate
from restful.model.query import QueryOneInstance
from restful.model.tables import Role
from restful.response import ResponseSuccess


class RoleInfo(Resource):
    @login_required_current_user_generate
    @uid_required_target_user_generate
    def get(self,target_user,current_user):
        role = QueryOneInstance(Role,{'uid':target_user.id})
        return ResponseSuccess(data={
            'admin':role.admin,
            'role':role.role,
        })